<?php 
	class Resource_Model extends CI_Model
	{
		function __construct(){
			parent::__construct();
		}
		
		function insert_resource($senderID,$type,$title,$content,$time,$downloadNumber,$URL)
		{
			$data = array(
					'senderID'=>$senderID,
					'type'=>$type,
					'title'=>$title,
					'content'=>$content,
					'time'=>$time,
					'downloadNumber'=>$downloadNumber,
					'URL'=>$URL);
			
			$this->db->insert('resource',$data);
		}
		
		function update_resource($ID,$senderID,$type,$title,$content,$time,$downloadNumber,$URL)
		{
			$data = array(
					'senderID'=>$senderID,
					'type'=>$type,
					'title'=>$title,
					'content'=>$content,
					'time'=>$time,
					'downloadNumber'=>$downloadNumber,
					'URL'=>$URL);
			$this->db->where('ID',$ID);
			$this->db->update('resource',$data);
		}
		 
		function delete_resource($ID)
		{
			$this->db->where('ID',$ID);
			$this->db->delete('resource');
		}
		
		function query_resource($limit, $offset)
		{
			return $this->db->get('resource'*$limit, ($offset-1)*$limit);
			
		}
		
		function query_resource_by_ID($ID)
		{
			$this->db->where("ID", $ID);
			return $this->db->get("resource");
		}
		
		function getALL()
		{
		return $this->db->get("resource");
	    }
		
	}
?>